//
//  Staic_TopCell.m
//  penzer
//
//  Created by caiyc on 2018/10/13.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "Staic_TopCell.h"
#define selectColor RGB(74,217,255)
#define nomalColor RGB(255,255,255)
#define NUMCOLOR RGBA(254, 220, 69, 1)
@implementation Staic_TopCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor = [UIColor clearColor];
    self.backgroundColor = [UIColor clearColor];
    self.botom_ScroView.backgroundColor = [UIColor clearColor];
    self.botom_ScroView.pagingEnabled = 1;
    self.botom_ScroView.delegate = self;
    self.botom_ScroView.showsHorizontalScrollIndicator = 0;
    [self initSbView];
    // Initialization code
}
-(void)initSbView{
    self.botom_ScroView.contentSize = CGSizeMake(screen_width*3, 0);
    for(UIView *view in [self.botom_ScroView subviews]){
        [view removeFromSuperview];
    }
    
    for(int i =0;i<3;i++){
        UIView *item = [[UIView alloc]initWithFrame:CGRectMake(screen_width*i, 0, screen_width, 180)];
        UIImageView *images = [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, screen_width-20, 180)];
        images.image = [UIImage imageNamed:@"topss"];
        [item addSubview:images];
        [self.botom_ScroView addSubview:item];
        
        if(i==1){
            UILabel *pepeo = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, screen_width/2, 30)];
            pepeo.textColor = selectColor;
            pepeo.textAlignment = NSTextAlignmentCenter;
            pepeo.text = @"引流总人数";
            [item addSubview:pepeo];
            self.num4 = [[UILabel alloc]initWithFrame:CGRectMake(0, 50, screen_width/2, 50)];
            self.num4 .textColor = NUMCOLOR;
            self.num4 .textAlignment = NSTextAlignmentCenter;
            self.num4 .text = [XTool countNumAndChangeformat:@"0"];
            self.num4 .font = [UIFont systemFontOfSize:30];
            [item addSubview:self.num4 ];
            UILabel *bussion = [[UILabel alloc]initWithFrame:CGRectMake(0, 110, screen_width/2, 20)];
            bussion.textColor = selectColor;
            bussion.textAlignment = NSTextAlignmentCenter;
            bussion.text = @"参与商家";
            bussion.font = [UIFont systemFontOfSize:15];
            [item addSubview:bussion];
            self.num6 = [[UILabel alloc]initWithFrame:CGRectMake(0,130, screen_width/2, 30)];
            self.num6 .textColor = selectColor;
            self.num6 .textAlignment = NSTextAlignmentCenter;
            self.num6 .text = @"0";
            self.num6 .font = [UIFont systemFontOfSize:25];
            [item addSubview:self.num6 ];
            
            UILabel *gift = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 20, screen_width/2, 30)];
            gift.textColor = selectColor;
            gift.textAlignment = NSTextAlignmentCenter;
            gift.text = @"直播礼物总价值";
            [item addSubview:gift];
            self.num5 = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 50, screen_width/2, 50)];
            self.num5.textColor = NUMCOLOR;
            self.num5.textAlignment = NSTextAlignmentCenter;
            self.num5.text = @"0";
            self.num5.font = [UIFont systemFontOfSize:30];
            [item addSubview:self.num5];
            
            UILabel *liftcat = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 110, screen_width/2, 20)];
            liftcat.textColor = selectColor;
            liftcat.textAlignment = NSTextAlignmentCenter;
            liftcat.text = @"礼物品类";
            liftcat.font = [UIFont systemFontOfSize:15];
            [item addSubview:liftcat];
            
            self.num7 = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2,130, screen_width/2, 30)];
            self.num7.textColor = selectColor;
            self.num7.textAlignment = NSTextAlignmentCenter;
            self.num7.text = @"0";
            self.num7.font = [UIFont systemFontOfSize:25];
            [item addSubview:self.num7];
        }else if(i==2){
            UILabel *pepeo = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, screen_width, 40)];
            pepeo.textColor = [UIColor whiteColor];
            pepeo.textAlignment = NSTextAlignmentCenter;
            pepeo.text = @"中奖率";
            [item addSubview:pepeo];
            self.num8 = [[UILabel alloc]initWithFrame:CGRectMake(0, 60, screen_width, 40)];
            self.num8.textColor = NUMCOLOR;
            self.num8.textAlignment = NSTextAlignmentCenter;
            self.num8.text = [XTool countNumAndChangeformat:@"0"];
            self.num8.font = [UIFont systemFontOfSize:30];
            [item addSubview:self.num8];
            UILabel *bussion = [[UILabel alloc]initWithFrame:CGRectMake(0, 110, screen_width/2, 20)];
            bussion.textColor = selectColor;
            bussion.textAlignment = NSTextAlignmentCenter;
            bussion.text = @"虚拟物品";
            bussion.font = [UIFont systemFontOfSize:15];
            [item addSubview:bussion];
            self.num9 = [[UILabel alloc]initWithFrame:CGRectMake(0,130, screen_width/2, 30)];
            self.num9.textColor = selectColor;
            self.num9.textAlignment = NSTextAlignmentCenter;
            self.num9.text = @"0";
            self.num9.font = [UIFont systemFontOfSize:25];
            [item addSubview:self.num9];
            //            UILabel *gift = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 20, screen_width/2, 50)];
            //            gift.textColor = selectColor;
            //            gift.textAlignment = NSTextAlignmentCenter;
            //            gift.text = @"已结束";
            //            [item addSubview:gift];
            //            UILabel *giftValue = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 60, screen_width/2, 50)];
            //            giftValue.textColor = NUMCOLOR;
            //            giftValue.textAlignment = NSTextAlignmentCenter;
            //            giftValue.text = @"251000";
            //            giftValue.font = [UIFont systemFontOfSize:30];
            //            [item addSubview:giftValue];
            UILabel *liftcat = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 110, screen_width/2, 20)];
            liftcat.textColor = selectColor;
            liftcat.textAlignment = NSTextAlignmentCenter;
            liftcat.text = @"已结束";
            liftcat.font = [UIFont systemFontOfSize:15];
            [item addSubview:liftcat];
            self.num10 = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2,130, screen_width/2, 30)];
            self.num10.textColor = selectColor;
            self.num10.textAlignment = NSTextAlignmentCenter;
            self.num10.text = @"0";
            self.num10.font = [UIFont systemFontOfSize:25];
            [item addSubview:self.num10];
        }else{
            UILabel *pepeo = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, screen_width, 40)];
            pepeo.textColor = [UIColor whiteColor];
            pepeo.textAlignment = NSTextAlignmentCenter;
            pepeo.text = @"直播总场次";
            [item addSubview:pepeo];
            self.num1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 60, screen_width, 40)];
            self.num1.textColor = NUMCOLOR;
            self.num1.textAlignment = NSTextAlignmentCenter;
            self.num1.text = @"0";
          //  pepeos.text = [NSString stringWithFormat:@"%@",dic[@""]];
            self.num1.font = [UIFont systemFontOfSize:30];
            [item addSubview:self.num1];
            UILabel *bussion = [[UILabel alloc]initWithFrame:CGRectMake(0, 110, screen_width/2, 20)];
            bussion.textColor = selectColor;
            bussion.textAlignment = NSTextAlignmentCenter;
            bussion.text = @"正在直播";
            bussion.font = [UIFont systemFontOfSize:15];
            [item addSubview:bussion];
            self.num2 = [[UILabel alloc]initWithFrame:CGRectMake(0,130, screen_width/2, 30)];
            self.num2.textColor = selectColor;
            self.num2.textAlignment = NSTextAlignmentCenter;
            self.num2.text = @"0";
            self.num2.font = [UIFont systemFontOfSize:25];
            [item addSubview:self.num2];
            //            UILabel *gift = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 20, screen_width/2, 50)];
            //            gift.textColor = selectColor;
            //            gift.textAlignment = NSTextAlignmentCenter;
            //            gift.text = @"已结束";
            //            [item addSubview:gift];
            //            UILabel *giftValue = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 60, screen_width/2, 50)];
            //            giftValue.textColor = NUMCOLOR;
            //            giftValue.textAlignment = NSTextAlignmentCenter;
            //            giftValue.text = @"251000";
            //            giftValue.font = [UIFont systemFontOfSize:30];
            //            [item addSubview:giftValue];
            UILabel *liftcat = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2, 110, screen_width/2, 20)];
            liftcat.textColor = selectColor;
            liftcat.textAlignment = NSTextAlignmentCenter;
            liftcat.text = @"已结束";
            liftcat.font = [UIFont systemFontOfSize:15];
            [item addSubview:liftcat];
            self.num3 = [[UILabel alloc]initWithFrame:CGRectMake(screen_width/2,130, screen_width/2, 30)];
            self.num3.textColor = selectColor;
            self.num3.textAlignment = NSTextAlignmentCenter;
            self.num3.text = @"0";
            // NSString *nums = [NSString stringWithFormat:@"%@",dic[@"finacttotal"]];
            //giftcat_Num.text = [XTool countNumAndChangeformat:nums];
            self.num3.font = [UIFont systemFontOfSize:25];
            [item addSubview:self.num3];
        }
        //        UILabel *pepeos = [[UILabel alloc]initWithFrame:CGRectMake(0, 70, screen_width/2, 50)];
        //        pepeos.textColor = NUMCOLOR;
        //        pepeos.textAlignment = NSTextAlignmentRight;
        //        pepeos.text = @"251000";
        //        pepeos.font = [UIFont systemFontOfSize:30];
        //        [item addSubview:pepeos];
        
    }
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSInteger index = scrollView.contentOffset.x/screen_width;
    if(index==0){
        self.topL.backgroundColor = selectColor;
        self.topC.backgroundColor = nomalColor;
        self.topR.backgroundColor = nomalColor;
    }else if (index==1){
        self.topL.backgroundColor = nomalColor;
        self.topC.backgroundColor = selectColor;
        self.topR.backgroundColor = nomalColor;
    }else{
        self.topL.backgroundColor = nomalColor;
        self.topC.backgroundColor = nomalColor;
        self.topR.backgroundColor = selectColor;
    }
}
-(NSMutableAttributedString *)str:(NSString *)str{
    NSMutableAttributedString * attributedText = [[NSMutableAttributedString alloc] initWithString:str];
    [attributedText setAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} range:NSMakeRange(attributedText.length-1, 1)];
    return attributedText;
}
-(void)bindData:(NSDictionary *)dic{
    self.num1.attributedText = [self str:[NSString stringWithFormat:@"%@场",dic[@"acttotal"]]];
    self.num2.attributedText =[self str: [NSString stringWithFormat:@"%@场",dic[@"nowacttotal"]]];
    self.num3.attributedText =[self str: [NSString stringWithFormat:@"%@场",dic[@"finacttotal"]]];
    self.num4.attributedText =[self str: [NSString stringWithFormat:@"%@人",dic[@"man_actnum"]]];
    self.num5.attributedText = [self str: [NSString stringWithFormat:@"%@元",dic[@"goods_total"]]];
    self.num6.attributedText = [self str: [NSString stringWithFormat:@"%@家",dic[@"storetotal"]]];
    self.num7.attributedText = [self str: [NSString stringWithFormat:@"%@种",dic[@"goods_cattotal"]]];
    self.num8.text = [NSString stringWithFormat:@"%@",dic[@"prizerate"]];
    self.num9.text = [NSString stringWithFormat:@"%@",dic[@"xunirate"]];
    self.num10.text = [NSString stringWithFormat:@"%@",dic[@"shirate"]];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
